﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace RAMED
{
    public partial class Imageviewerexportes : Form
    {
        public List<Image> images = new List<Image>();
        public ExportésForm exportesf = new ExportésForm();
        int i = -1;

        public Imageviewerexportes()
        {
            InitializeComponent();
        }
        private void mettreAjourButtons()
        {
            if (i == images.Count - 1)
            {
                suivantButton.Visible = false;

            }
            else
                suivantButton.Visible = true;
            if (i == 0)
            {
                précedentButton.Visible = false;
            }
            else
                précedentButton.Visible = true;
        }
        private void précedentButton_Click(object sender, EventArgs e)
        {
            i--;
            pictureBox1.Image = images.ElementAt(i);
            mettreAjourButtons();
        }

        private void suivantButton_Click(object sender, EventArgs e)
        {
            i++;
            pictureBox1.Image = images.ElementAt(i);
            mettreAjourButtons();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            openFileDialogPv.Filter = "Jpg files (*.jpg)|*.jpg";

            if (openFileDialogPv.ShowDialog() == DialogResult.OK)
            {
                Image image = Image.FromFile(openFileDialogPv.FileName);


                images.Add(image);
                i++;
                pictureBox1.Image = images.ElementAt(i);
                mettreAjourButtons();
            }
        }

        private void Imageviewerexportes_Load(object sender, EventArgs e)
        {
            if (images.Count > 0)

                pictureBox1.Image = images.ElementAt(0);
            else
            {
                précedentButton.Visible = false;
                suivantButton.Visible = false;
            }
        }

        private void Button21_Click(object sender, EventArgs e)
        {
            this.WindowState = FormWindowState.Minimized;
        }

        private void button3_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            foreach (Image image in images)
            {
                Image_Message_exporté imageepo = new Image_Message_exporté() { Image_ = utitlitaire.ConvertirImageABinary(image) };
                exportesf.imageexporte.Add(imageepo);
            }



            this.Dispose();
        }
    }
}
